import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

import 'model/ListData.dart';

class HaHa extends StatefulWidget {
  const HaHa({super.key});

  @override
  State<HaHa> createState() => _HaHaState();
}

class _HaHaState extends State<HaHa> {
  List<ListData> contentList = [];

  @override
  void initState() {
    super.initState();
    contentList.add(ListData('第一名', '张三', 'http://gips3.baidu.com/it/u=3886271102,3123389489&fm=3028&app=3028&f=JPEG&fmt=auto?w=1280&h=960'));
    contentList.add(ListData('第二名', '李四', 'http://gips0.baidu.com/it/u=1690853528,2506870245&fm=3028&app=3028&f=JPEG&fmt=auto?w=1024&h=1024'));
    contentList.add(ListData('第一名', '张三', 'https://gips3.baidu.com/it/u=1039279337,1441343044&fm=3028&app=3028&f=JPEG&fmt=auto&q=100&size=f1024_1024'));

  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemCount: contentList.length,
        itemBuilder: (BuildContext context, int index){
          return HomeItem(contentList[index]);
    });
  }
}

class HomeItem extends StatelessWidget {

  final ListData listData;
  HomeItem(this.listData);

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.all(10),
      decoration: BoxDecoration(
        border: Border.all(color: Colors.orange,width: 5)
      ),
      margin: EdgeInsets.all(5),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: [
        Text(listData.title),
        Text(listData.name),
        Image.network(listData.imageUrl)
      ],),
    );
  }
}
